﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConferenceArranger.ConferenceComponent;
using ConferenceArranger.BusinessRules;

namespace ConferenceArranger.Strategy
{
        /// <summary>
        /// given a list of sessions from Session Scheduler
        /// arrange sessions into different tracks
        /// pass a list of tracks to Conference object
        /// </summary>
        class TrackProcessor
        {
            //input 
            List<Session> sessionList;

            //output
            List<Track> trackList;

            public TrackProcessor(List<Session> sessionList)
            {
                this.sessionList = sessionList;
                this.trackList = new List<Track>();
                ArrangeTracks();
            }

            /// <summary>
            /// arrange sessions into tracks
            /// </summary>
            public void ArrangeTracks()
            {
                int NoOfSession = SessionHelper.MAX_NUM_OF_SESSIONS;
                for (int i = 0; i < sessionList.Count; i += NoOfSession)
                {
                    Track newTrack = new Track();
                    DateTime trackDate = SessionHelper.GetNextStartDate();
                    for (int j = 0; j < NoOfSession; j++ )
                    {
                        newTrack.AddSession(sessionList[i + j], trackDate);
                    }
                    trackList.Add(newTrack);
                }
            }

            public List<Track> GetOutput()
            {
                return trackList;
            }
        }
    
}
